	ORG $1001-2
	DW $1001
	
	DW $100B,0
	DB $9E,"4109",0,0,0
	
start	SEI
	STA $FF3F
	;
	LDA #$41
	STA $FF19
	LDA #$51
	STA $FF15
	;                   
;	LDX #Channel1 & 255
;	LDY #Channel1 >> 8
;	JSR set_ch1
;	;
;	LDX #Channel2 & 255
;	LDY #Channel2 >> 8
;	JSR set_ch2
	;
	JSR PLAYER_FREQ_INIT
	;
	; ---
	;        
	LDY #$00
	LDX #$00
delay	INX
	BNE delay
	INY
	BNE delay
	;
x0	LDA x1+1
	CLC
	ADC #$A0
	BCC x2
	LDA #$00
x2	STA x1+1
	;
x1	LDA #$00
	LDX #$00
sync0	INX
	CMP $FF1D
	BNE sync0
	;
	LDX $FF1C
	CPX #$FE
	BNE sync0
	;
	DEC $FF19
	;
	CMP #$00
	BNE sound_only
	;
	JSR PLAYER
	;
	JMP x3
sound_only
	;JSR PLAYER_SOUND
	;
x3	INC $FF19
	;
	;LDA $FF12
	;AND #$03
	;JSR $FB10
	;LDA $FF0E
	;JSR $FB10
	;LDA #$0D
	;JSR $FFD2
	;
kdelay	LDY #$00
	BEQ kcheck
	DEY 
	JMP kend
	
kcheck	LDA #$BF
	STA $FD30
	STA $FF08
	LDA $FF08
	CMP #$F7
	BNE x5
	;
	; do something on keypress
	;
x5	;
	LDY #$04    
kend	STY kdelay+1
	;
	JMP x0
	;
	
	org $D000
	include "!player.asm"
	include "music.asm"
	
	